***************************************************************** * * BASICS.ASM Source Code * by Sandy Mossberg * Copyright(c) 1989 * MindCraft Publ. Corp. * Concord, MA 01742 **************************************************************** * StartUp start * * Startup tool sets: * * Exit: CC = no error, CS = abort program * ***************************************************************** using GlobalData ; ; DPHndl and DPPtr equated in main program. ; ; Calculate direct page space for tool sets: ; QDDPage equ $0000 ;DP offests: QuickDraw II.....3 pages EMDPage equ QDDPage+$300 ; Event Manager....1 page CtlDPage equ EMDPage+$100 ; Control Manager..1 page MenuDPage equ CtlDPage+$100 ; Menu Manager.....1 page LEDPage equ MenuDPage+$100 ; LineEdit.........1 page SFDPage equ LEDPage+$100 ; Standard File....1 page FontDPage equ SFDPage+$100 ; Font Manager.....1 page PrintDPage equ FontDPage+$100 ; Print Manager....2 pages SANEDPage equ PrintDPage+$200 ; SANE.............1 page DPageSize equ SANEDPage+$100 ;size of direct page space required ; Startup first 3 tool sets: _TLStartUp ;----start Tool Locator pha ;space for result _MMStartUp ;----start Memory Manager jsr HandlErr PullWord MasterID ;save master ID _MTStartUp ;----start Miscellaneous Tools ; Allocate direct page memory for tool sets: PushLong #0 ;space for result PushLong #DPageSize ;size of direct page space PushWord MasterID ;master ID PushWord #$C005 ;locked, fixed, aligned, fixed bank PushLong #0 ;bank $00 is the fixed bank _NewHandle ;allocate space jsr HandlErr PullLong DPHndl ;save handle to DP space lda [DPHndl] ;dereference DP handle to obtain sta DPPtr ; ptr (lo) to DP space ; Startup other tool sets: PushWord DPPtr ;ptr to direct page for Quickdraw II PushWord #ScreenMode ;640x200 super hi-res PushWord #0 ;default pixel map is screen width PushWord MasterID ;master ID _QDStartUp ;----start QuickDraw II jsr HandlErr lda DPPtr clc adc #EMDPage pha ;direct page for Event Manager PushWord #0 ;default size of event queue is 20 PushWord #0 ;minimum X clamp value for mouse PushWord #ScreenWidth ;max X clamp is screen width PushWord #0 ;minimum Y clamp value for mouse PushWord #200 ;max Y clamp is screen height PushWord MasterID ;master ID _EMStartUp ;----start Event Manager jsr HandlErr ; Print "One moment please..." message: PushWord #10 ;start in upper left corner of screen PushWord #10 _MoveTo PushWord #0 ;black background _SetBackColor PushWord #$0F ;white text _SetForeColor PushLong #StrMoment _DrawString _ShowCursor ;show cursor in case of boot volume mount ; Load RAM-based tools: FindBootVol _GetFileInfoGS GFIParm ;look for boot tools directory bcc LoadTools ;boot volume online jsr MountBoot ;no boot volume so mount it bcc FindBootVol ;user mounted boot volume--check it jsr ShutDown1 ;shutdown tools we started up sec ;CS = signal program abortion rts LoadTools PushLong #ToolTable ;ptr to tool table _LoadTools ;load all tools in table jsr HandlErr ; Continue to start tool sets: PushWord MasterID ;master ID _WindStartUp ;----start Window Manager PushWord MasterID ;master ID lda DPPtr clc adc #CtlDPage pha ;direct page for Control Manager _CtlStartUp ;----start Control Manager PushWord MasterID ;master ID lda DPPtr clc adc #MenuDPage pha ;direct page for Menu Manager _MenuStartUp ;----start Menu Manager PushWord MasterID ;master ID lda DPPtr clc adc #LEDPage pha ;direct page for LineEdit _LEStartUp ;----start LineEdit jsr HandlErr PushWord MasterID ;master ID _DialogStartUp ;----start Dialog Manager PushWord MasterID ;master ID lda DPPtr clc adc #SFDPage pha ;direct page for Standard File _SFStartUp ;----start Standard Files _ScrapStartUp ;----start Scrap Manager _DeskStartUp ;----start Desk Manager _ListStartUp ;----start List Manager PushWord MasterID ;master ID lda DPPtr clc adc #FontDPage pha ;direct page for Font Manager _FMStartUp ;----start Font Manager jsr HandlErr PushWord MasterID ;master ID lda DPPtr clc adc #PrintDPage pha ;direct pages for Print Manager _PMStartUp ;----start Print Manager jsr HandlErr lda DPPtr clc adc #SANEDPage pha ;direct page for SANE _SANEStartUp ;----start SANE _SchStartUp ;----start Scheduler _ADBStartUp ;----start Apple Desktop Bus _QDAuxStartUp ;----start QuickDraw II Auxiliary _IMStartUp ;----start Integer Math _TextStartUp ;----start Text rts ;CC = signal program continuation ;................................................................ ; ; StartUp data: ; GFIParm anop ;GetFileInfo parmlist (GS/OS class 1) dc i2'2' ;pCount = 2 dc i4'ToolsPath' ;ptr to tools boot directory (input) ds 2 ;access (result) ToolsPath anop ;GFI input string (GS/OS class 1) dc i2'TPEnd-ToolsPath-2' ;length word dc c'*/SYSTEM/TOOLS/' ;pathname chars TPEnd anop StrMoment str ' One moment please...' ToolTable anop ;RAM tools to load (System Disk 4.0+) dc i2'TTSize/4' ;number of tool sets dc i2'$0E,$0203' ;Window Manager dc i2'$0F,$0202' ;Menu Manager dc i2'$10,$0206' ;Control Manager dc i2'$12,$0205' ;QuickDraw Auxiliary dc i2'$13,$0202' ;Print Manager dc i2'$14,$0202' ;LineEdit dc i2'$15,$0203' ;Dialog Manager dc i2'$16,$0104' ;Scrap Manager dc i2'$17,$0202' ;Standard File Operations dc i2'$1B,$0204' ;Font Manager dc i2'$1C,$0203' ;List Manager TTSize equ *-ToolTable-2 ;number of table bytes (-2 number bytes) end ***************************************************************** * ShutDown start * * Shutdown tools sets: * * Entry: ShutDown1 - shutdown tool sets if program aborted * ***************************************************************** using GlobalData _TextShutDown ;shutdown tools in reverse _IMShutDown ; order of their startup _QDAuxShutDown _ADBShutDown _SchShutDown _SANEShutDown _PMShutDown _FMShutDown _ListShutDown _DeskShutDown _ScrapShutDown _SFShutDown _DialogShutDown _LEShutDown _MenuShutDown _CtlShutDown _WindShutDown ShutDown1 entry ;shutdown tool sets if program aborted _EMShutDown _QDShutDown PushLong DPHndl ;handle to direct page space _DisposeHandle ;deallocate direct page space _MTShutDown PushWord MasterID ;master ID _MMShutDown _TLShutDown rts end ***************************************************************** * HandlErr start * * Check for error and handle fatal error: * ***************************************************************** bcs FatalErr ;error detected rts ;no error on carry clear FatalErr pha ;error code in A reg PushLong #0 ;use default failure message _SysFailMgr ;die a horrible death end ***************************************************************** * MountBoot start * * Mount boot volume: * * Exit: CC = continue, CS = abort program * ***************************************************************** _GetBootVolGS GBVParm jsr HandlErr lda BVStr ;convert from GS/OS class 1 input xba ; string to standard P-string sta BVStr pha ;space fpr result PushWord #185 ;upper left X coordinate PushWord #50 ;upper left Y coordinate PushLong #StrBootVol ;ptr to prompt string PushLong #BVStr+1 ;ptr to boot volume name string PushLong #StrOk ;ptr to button 1 string PushLong #StrAbort ;ptr to button 2 string _TLMountVolume pla ;button ID number cmp #2 beq Done ;CS = abort button hit clc ;CC = OK button hit Done rts ;................................................................ ; ; MountBoot data: ; GBVParm anop ;GetBootVol parmlist (GS/OS class 1) dc i2'1' ;pCount = 1 dc i4'BVBuf' ;ptr to volume name buffer (output) BVBuf anop ;boot volume path buffer (GS/OS class 1) dc i2'BVEnd-BVStr' ;buffer length BVStr ds 19 ;input string BVEnd anop StrOk str 'OK' StrAbort str 'Abort' StrBootVol str 'Insert the boot volume:' end